package com.lollipop.synthential.examination;

/**
 * @Author: J.K
 * @Date: 2021-05-28 15:21
 * @Description: 判断字符串是否是mac地址
 */
public class MacAddress {
    public static void main(String[] args) {
        String macString = "01:FF:1C:2F:2A:74";
        boolean isMac = stringIsMac(macString);
        System.out.println(isMac);
    }

    private static boolean stringIsMac(String val) {
        String macRegex = "^([A-Fa-f0-9]{2}[-,:]){5}[A-Fa-f0-9]{2}$";

        if (val.matches(macRegex)) {
            return true;
        } else {
            return false;
        }
    }
}
